package jtk.project4.fleet.field;

import javax.swing.SortOrder;

import jtk.project4.fleet.domain.Employee;
import jtk.project4.fleet.domain.Equipment;
import nl.coderight.jazz.form.field.TextField;

import nl.coderight.jazz.form.control.GroupControl;
import nl.coderight.jazz.form.field.TableField;
import nl.coderight.jazz.form.field.TableField.AutoResizeMode;

public class UpdateMeterTableField extends GroupControl<Employee>{
	
	private TableField<Equipment> updatemeterTable;
	private TextField summaryField;
	
	public UpdateMeterTableField(String bindID){
		setBindID(bindID);
		createFields();
		createLayout();
	}
	
	private void createFields(){
		//setup table
		updatemeterTable = new TableField<Equipment>("equipments","equipment");
		updatemeterTable.setAutoResizeMode(AutoResizeMode.AUTOFIT);
		updatemeterTable.setAutofitColumn("ownership");
		updatemeterTable.getSelectionValues();
		updatemeterTable.setShowGrid(true);
		
		updatemeterTable.addColumn("Identification","ownership");
		updatemeterTable.addColumn("Current Meter","warrantyDate");
		updatemeterTable.addColumn("New Meter","warrantyMeter");
		updatemeterTable.addColumn("Type","location");
		updatemeterTable.addColumn("Last Updated","category");
		
		
		
		//Sort
		updatemeterTable.sort("unit", SortOrder.ASCENDING);
		
		summaryField = new TextField("Summary", 20);
		summaryField.setEditable(false);
		summaryField.setValue("Seharusnya Summary dari database");
	}
	
	
	private void createLayout(){
		addField(updatemeterTable, NORTH);
		addField(summaryField, SOUTH);
	}
	
}
